var express = require("express");
var router = express.Router();
const { uploadFiles } = require("../utils/handleFiles");

router.post("/uploadImages", function (req, res, next) {
    const uploadImages = uploadFiles({
        path: "./public/temp", //图片上传成功后存储的位置
        key: "file", //
        // size: 5000
    });

    uploadImages(req, res, (err) => {
        if (err) {
            console.log("图片上传失败", err);
        } else {
            console.log("图片上传成功");
            console.log(req.files);
            res.send({
                message: "上传成功",
                status: 1,
                data: req.files[0].filename,
            });
        }
    });
});

module.exports = router;
